﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Documentanalysis
{
    public partial class SearchSelect : Form
    {
        public SearchSelect()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            folderBrowserDialog1.Description = "请选择文件夹";
            DialogResult result = folderBrowserDialog1.ShowDialog();
            if (result == DialogResult.OK)
            {

                string folderName = folderBrowserDialog1.SelectedPath;
                if (folderName != "")
                {
                    ListViewItem li = new ListViewItem();
                    li.SubItems[0].Text = folderName;
                    li.SubItems.Add("");
                    listView1.Items.Add(li);
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (listView1.Items.Count > 0)
            {
                if (textBox1.Text != "")
                {
                    List<string> folderArray = ((Main)this.Owner).folderArray;
                    folderArray = new List<string>();
                    foreach (ListViewItem item in listView1.Items)
                    {
                        folderArray.Add(item.SubItems[0].Text);
                    }
                    ((Main)this.Owner).folderArray = folderArray;
                    ((Main)this.Owner).searchCondition = textBox1.Text;
                    this.button3.DialogResult = DialogResult.OK;
                    button3.PerformClick();
                }
                else
                {
                    MessageBox.Show("请输入查询条件！", "提示");
                }
            }
            else
            {
                MessageBox.Show("请至少选择一个文件夹进行查询！", "提示");
            }
        }

        private void FolderSelect_Load(object sender, EventArgs e)
        {
            listView1.MouseClick += new MouseEventHandler(listViewtcmedicineSearchMouseClick);
            listView1.Scrollable = true;
        }

        private void listViewtcmedicineSearchMouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                contextMenuStrip1.Show(listView1, e.Location);
            }
        }

        private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
            listView1.Items.Remove(listView1.SelectedItems[0]); 
        }
    }
}
